<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <title></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>品规库编辑</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="javascript:void(0)">品规库</a></li>
            <li class="active"><a href="javascript:void(0)">品规库编辑</a></li>
        </ol>
    </section>
    <section class="content">
        <div class=" box box-primary">
            <div class="box-header"></div>
            <!-- form start -->
            <form role="form" id ="formSubmit" class="form-horizontal" action="saveOrEditDrugQualitySpec.html?opType=${opType}" method="post">
                <div class="box-body">
                    <div class="form-group">
                        <label class="col-sm-2 text-right"><span style="color:red">*</span>品规编码：</label>
                        <div class="col-sm-10">
                            <input class="form-control" placeholder="品规编码" type="text" value="${stdDrugQualitySpec.qualitySpecCode}" id="qualitySpecCode"  name="qualitySpecCode" maxlength="200">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 text-right"><span style="color:red">*</span>品规名称：</label>
                        <div class="col-sm-10">
                            <input class=" form-control" placeholder="品规名称" type="text" value="${stdDrugQualitySpec.qualitySpecName}" id="qualitySpecName" name="qualitySpecName" maxlength="200">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 text-right">品规英文名：</label>
                        <div class="col-sm-10">
                            <input class=" form-control" placeholder="品规英文名" type="text" value="${stdDrugQualitySpec.qualitySpecNameEng}" id="qualitySpecNameEng" name="qualitySpecNameEng" maxlength="200">
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label class="col-sm-2 text-right"><span style="color:red">*</span>剂型</label>
                        <div class="col-sm-10">
                            <input class=" form-control" placeholder="剂型" type="text" value="${stdDrugQualitySpec.form }" id="form" name="form" maxlength="200">
                        </div>
                   </div>
                   
                   <div class="form-group">
                        <label class="col-sm-2 text-right"><span style="color:red">*</span>规格</label>
                        <div class="col-sm-10">
                            <input class=" form-control" placeholder="规格" type="text" value="${stdDrugQualitySpec.spec }" id="spec" name="spec" maxlength="200">
                        </div>
                   </div>
                   <input class=" form-control" type="hidden" value="${opType}" id="opType" name="opType">
                   <input class=" form-control" type="hidden" value="${stdDrugQualitySpec.qualitySpecId}" id="qualitySpecId" name="qualitySpecId">
                </div>
                 <div class="box-footer text-center">
                    <button type="button" onclick="save();" class="btn btn-success btn-sm">保 &nbsp; 存</button>
                    <button type="button" onclick="back();" class="btn btn-danger btn-sm">返 &nbsp; 回</button>
                </div>
            </form>
        </div>
    </section>
      <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">

    function save(){
    	if (!validate()) {
			return;
		}
		$.HN.message.confirm('确定要保存吗？', '', '').on(function (e) {
               if (e) {
			$("#formSubmit").ajaxSubmit({
				dataType : "json",
				timeout: 10000,
				success : function(result, statusText) {
					if (result.success) {
						
						$.HN.message.alert("保存成功！", "消息", "success", function() {
							window.location.href="${ctx}/stdDrugQualitySpec/toDrugQualitySpecList.html";
						});
					} else {
						$.HN.message.alert(result.msg || "", "消息", "error");
					}
				}
				});
         }
       });
    }
    
    function validate(){
    	    var qualitySpecCode = $.trim($('#qualitySpecCode').val());
			var qualitySpecName = $.trim($('#qualitySpecName').val());
			var form = $.trim($('#form').val());
			var spec = $.trim($('#spec').val());
			if(qualitySpecCode==""){
           $.HN.message.alert('品规编码不能为空！请输入品规编码', '提示信息', 'warn');
             return false;
           }else if (qualitySpecCode.length>36){
             $.HN.message.alert("品规编码太长！请重新输入", "消息", "warn");
             return  false;
            }
			
       if(qualitySpecName==""){
            $.HN.message.alert('品规名称不能为空！请输入品规名称', '提示信息', 'warn');
            return false;
       }else if (qualitySpecName.length>512){
           $.HN.message.alert("品规名称太长！请重新输入", "消息", "warn");
           return  false;
       }
     
       if(form==""){
            $.HN.message.alert('剂型不能为空！', '提示信息', 'warn');
            return false;
       }else if (form.length>36){
           $.HN.message.alert("剂型太长！请重新输入", "消息", "warn");
           return  false;
       }
       if(spec==""){
           $.HN.message.alert('规格不能为空！', '提示信息', 'warn');
           return false;
      }else if (spec.length>36){
          $.HN.message.alert("规格太长！请重新输入", "消息", "warn");
          return  false;
      }
       return true;
   }

     function back(){
     	window.location.href="toDrugQualitySpecList.html";
     }
   
    </script>
</body>
</html>
